<!--  -->
<template>
  <publicPage isNavbar bgColor="#FFFFFF">
    <view slot="navbar">
      <u-navbar :placeholder="true" bgColor="#FFFFFF">
        <view slot="left"></view>
        <view slot="center" class="disFlxAC">微信授权</view>
        <view slot="right"></view> </u-navbar
    ></view>
    <view
      class="disFlxCC"
      style="
        padding-top: 134rpx;
        padding-bottom: 60rpx;
        border-top: solid 1px #f5f5f5;
        border-bottom: solid 1px #f5f5f5;
      "
    >
      <image
        src="https://onelive.obs.cn-south-1.myhuaweicloud.com/uniapp/static/padLogo.png"
        style="width: 160rpx; height: 160rpx"
      />
      <view class="pt-16">医健互联</view>
    </view>
    <view class="px-20 pt-30">
      <view class="fz-16">医健互联申请绑定微信</view>
      <view class="fz-14 color9 pt-9"
        >确认授权后您可以将平台余额提现至您的微信零钱</view
      >
      <button class="mt-39" type="primary" @click="bandOpenId">确认授权</button>
    </view>

    <u-popup :show="pShow" :closeOnClickOverlay="false" :round="10">
    <view class="statusPopup">
      <image
        src="https://onelive.obs.cn-south-1.myhuaweicloud.com/uniapp/static/image220701%2817%29.png"
        style="width: 160rpx; height: 160rpx"
      />
      <view class="fw-6 pt-10">绑定成功</view>
      <view class="px-50 pt-30 color8 tc">
        您的平台账户已成功绑定微信,可以正常提现到微信零钱了
      </view>
    </view>
  </u-popup>
  </publicPage>
</template>

<script>
import orderApi from "@/api/order.js";
export default {
  data() {
    return {
      postParams: {
        expid: "",
        code: "",
      },
      pShow: false
    };
  },
  onLoad(options) {
    if (options.scene) {
      this.postParams.expid = options.scene;
    } else {
      uni.showToast({
        title: "参数错误!!!",
        icon: "error",
      });
    }
  },
  methods: {
    bandOpenId() {
      const that = this;
      uni.login({
        success(res) {
          that.postParams.code = res.code;
          if (that.postParams.code) {
            orderApi.bandExpOpenId(that.postParams).then(() => {
              that.pShow = true
            });
          } else {
            uni.showToast({
              title: "授权错误,请重试!",
              icon: "none",
            });
          }
        },
        fail(err){
          uni.showToast({
            title: "授权错误,请重试",
            icon: "none",
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.statusPopup {
  padding: 100rpx 40rpx 100rpx 40rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
</style>